import "package:flutter/material.dart";
import "package:get/get.dart";

import '../../common/my_icon.dart';
import '../../controller/network/network_ctrl.dart';
import '../../utils/screenutil/fit.dart';

class NotNetwork extends StatelessWidget {
  String tip;

  NotNetwork({String tip}) : this.tip = tip ?? "网络连接不可用";

  // 查找网络控制器
  final _ctrl = Get.find<NetworkCtrl>();

  @override
  Widget build(BuildContext context) {
//    print(_ctrl.networkStatus.value);
//    print("网络状态");
    return Obx(
      () => !_ctrl.networkStatus.value
          ? Container(
              width: 640.f,
              height: 60.f,
              padding: EdgeInsets.symmetric(horizontal: 20.f),
              color: Color.fromRGBO(255, 237, 237, 1),
              child: Row(
                children: [
                  Icon(MyIcon.notNetwork, size: 30.f, color: Colors.red),
                  SizedBox(width: 10.f),
                  Text(
                    "$tip",
                    style: TextStyle(
                      fontSize: 24.f,
                      color: Colors.red,
                    ),
                  ),
                ],
              ),
            )
          : SizedBox.shrink(),
    );
  }
}
